﻿using System;
using System.Globalization;

namespace QuizzMe.ValueConverters
{
    /// <summary>
    /// Convert a rank (1,2,3,...) to the corresponding medal icon (gold, silver, ...)
    /// </summary>
    public class RankToMedalValueConverter : ImageConverter
    {
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int rank = (int)value;
            string name;

            switch (rank)
            {
                case 1:
                    name = "medal_gold";
                    break;
                case 2:
                    name = "medal_silver";
                    break;
                case 3:
                    name = "medal_bronze";
                    break;
                default:
                    name = "medal";
                    break;
            }

            return ImageFromResource(name);
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
